
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>

#include "lt_fat32.h"

//FILE *file;
int fd = -1;

int init_sector()
{
    fd = open("/dev/sdb", O_RDWR);

    if (fd < 0)
    {
      printf("can not open file\n");
      exit(0);
    }
    return 0;
}

int read_sector(int secno, char *buf, int size)
{
    lseek(fd, secno * 512, SEEK_SET);
    read(fd, buf, 512);      
}

int write_sector(int secno, char *buf, int size)
{
    lseek(fd, secno * 512, SEEK_SET);
    write(fd, buf, 512);    
}

DRIVER_t light_driver = 
{
	"hello",	
	init_sector,
	read_sector,
	write_sector,
	0,
};

